package com.yupi.picturebackend.service;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yupi.picturebackend.model.dto.user.UserQueryRequest;
import com.yupi.picturebackend.model.entity.User;
import com.yupi.picturebackend.model.vo.LoginUserVO;
import com.yupi.picturebackend.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 伍立权
* @description 针对表【user(用户)】的数据库操作Service
* @createDate 2025-03-27 21:25:05
*/
public interface UserService extends IService<User> {
    /**
     * 用户注册
     */
    long userRegister(String userAccount, String userPassword, String checkPassword);

    /**
     * 获取加密后的密码
     * @param userPassword
     * @return
     */
    String getEncryptPassword(String userPassword);

    /**
     * 用户登录
     */
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * 将用户对象转为用户Vo对象
     * @param user
     * @return
     */
    LoginUserVO getLoginUserVO(User user);

    /**
     * 获取当前登录用户
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 用户注销
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 根据 id 获取包装类
     */
    UserVO getUserVO(User user);

    /**
     * 获取请求的分页条件
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 将User集合转化成封装类型
     * @param records
     * @return
     */
    List<UserVO> getUserVOList(List<User> records);

    /**
     * 兑换会员
     * @param loginUser
     * @param vipCode
     * @return
     */
    boolean exchangeVip(User loginUser, String vipCode);

    /**
     * 判断是否为管理员
     * @param user
     * @return
     */
    boolean isAdmin(User user);

}
